<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>personal blog | Log in</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" th:href="@{/admin/dist/img/favicon.ico}"/>
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/admin/dist/css/font-awesome.min.css}">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/admin/dist/css/ionicons.min.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/admin/dist/css/adminlte.min.css}">
    <!--  layui  -->
    <link rel="stylesheet" th:href="@{/admin/plugins/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/admin/plugins/layui/css/modules/layer/default/layer.css}">
    <style>
        canvas {
            display: block;
            vertical-align: bottom;
        }
        #particles {
            background-color: #002B5A;
            position: absolute;
            top: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
        }
    </style>
</head>
<body class="hold-transition login-page" >
<div id="particles">

</div>
<div class="login-box">
    <div class="login-logo" style="color: #007bff;">
        <h1>personal blog</h1>
    </div>
    <!-- /.login-logo -->
    <div class="card">
        <div class="card-body login-card-body">
            <p class="login-box-msg">your personal blog , enjoy it</p>
            <form id="form" method="post">
                <div class="form-group has-feedback">
                    <span class="fa fa-user form-control-feedback" style="float: left;"></span>
                    <input type="text" id="userName" name="userName" class="form-control" style="width: 265px; margin-left: 25px" placeholder="请输入账号"
                           required="true">
                </div>
                <div class="form-group has-feedback">
                    <span class="fa fa-lock form-control-feedback" style="float: left;"></span>
                    <input type="password" id="password" name="password" class="form-control" style="width: 265px; margin-left: 25px" placeholder="请输入密码"
                           required="true">
                </div>
                <div class="row">
                    <div class="col-6">
                        <input type="text" class="form-control" name="verifyCode" style="margin-left: 25px;width: 140px;" placeholder="请输入验证码" required="true">
                    </div>
                    <div class="col-6">
                        <img id="vcodeImg" style="margin-left: 13px;" alt="单击图片刷新！" class="pointer" th:src="@{/checkCode}"
                             onclick="this.src='/checkCode?d='+new Date()*1">
                    </div>
                </div>
                <div class="form-group has-feedback"></div>
            </form>
            <div class="row">
                <div class="col-8">
                </div>
                <div class="col-4">
                    <button style="width: 68px;" id="submitBtn" class="btn btn-primary btn-block btn-flat">登录
                    </button>

                </div>
            </div>
        </div>
        <!-- /.login-card-body -->
    </div>
</div>
<!-- /.login-box -->

<!-- jQuery -->
<script th:src="@{/admin/plugins/jquery/jquery.min.js}"></script>
<!-- Bootstrap 4 -->
<script th:src="@{/admin/plugins/bootstrap/js/bootstrap.bundle.min.js}"></script>
<!--layui-->
<script th:src="@{/admin/plugins/layui/layui.all.js}"></script>
<!--背景配置-->
<script th:src="@{/admin/dist/js/plugins/particles.js}"></script>
<script th:src="@{/admin/dist/js/plugins/login-bg-particles.js}"></script>


<script th:inline="javascript">
    /*<![CDATA[*/
        $("#submitBtn").click(function () {
            $.ajax({
                type: "post",
                url: "/admin/login",
                data: $("#form").serialize(),
                dataType: "json", //返回数据类型
                success: function(data){
                    if(data.success){
                        layer.msg(data.message,{time:1000},function() {
                            window.location.href = "/admin/index";
                        })
                    }else{
                        layer.msg(data.message);
                        $("#vcodeImg").click();//切换验证码
                        $("input[name='code']").val("");//清空验证码输入框
                    }
                }

            });
        })

    /*]]>*/
</script>
</body>
</html>
